﻿using HK.Core.Common.Protocol;
using HK.Core.Common.Protocol.Data;

namespace HK.Editor.GUIEx.Protocol.Pagination
{
    /// <summary>
    /// 接口 : 分页信息
    /// </summary>
    public interface IPagination : IJsonData
    {
        /// <summary>
        /// 上一次页码索引
        /// </summary>
        int LastIndex { get; }
    
        /// <summary>
        /// 页码索引
        /// </summary>
        int Index { get; set; }
    
        /// <summary>
        /// 页数
        /// </summary>
        int PageSize { get; set; }
        
        /// <summary>
        /// 滚动条显示标志位 - 横轴
        /// </summary>
        bool HBarVisible { get; set; }
        
        /// <summary>
        /// 滚动条显示标志位 - 纵轴
        /// </summary>
        bool VBarVisible { get; set; }
        
        /// <summary>
        /// 取得当前开始索引
        /// </summary>
        /// <param name="iTotal">总数</param>
        /// <returns>当前开始索引</returns>
        int GetCurVisibleLength(int iTotal);
    
        /// <summary>
        /// 取得总页数
        /// </summary>
        /// <param name="iElementCount">Element总数</param>
        /// <returns>总页数</returns>
        int GetPageCount(int iElementCount);

        /// <summary>
        /// 取得当前分页可视范围
        /// </summary>
        /// <param name="iElementNum">元素个数</param>
        /// <param name="oStartIndex">开始索引(从0开始)</param>
        /// <param name="oEndIndex">结束索引s</param>
        /// <returns>当前分页可视范围</returns>
        bool GetVisibleRange(int iElementNum, out int oStartIndex, out int oEndIndex);
    
        /// <summary>
        /// 校验是否可分页
        /// </summary>
        /// <param name="iElementCount">Element总数</param>
        /// <returns>true:可分页; false:不可分页;</returns>
        bool IsPageable(int iElementCount);

        /// <summary>
        /// 重置索引
        /// </summary>
        void ResetIndex();
        
        /// <summary>
        /// 校验是否可以移动分页
        /// </summary>
        /// <returns>true:可; false:不可;</returns>
        bool IsMovePageEnable();

        /// <summary>
        /// 校验是否可以移动到上一页
        /// </summary>
        /// <returns>true:可; false:不可;</returns>
        bool IsMovePrevPageEnable();

        /// <summary>
        /// 校验是否可以移动到下一页
        /// </summary>
        /// <param name="iCount">数量</param>
        /// <returns>true:可; false:不可;</returns>
        bool IsMoveNextPageEnable(int iCount);
    }
}
